# Contributor: Duncan Bellamy <dunk@denkimushi.com>
# Maintainer: Duncan Bellamy <dunk@denkimushi.com>
# based on arch linux PKGBUILD
pkgname=py3-apache-arrow
pkgver=8.0.0
pkgrel=0
pkgdesc="multi-language toolbox for accelerated data interchange and in-memory processing"
url="https://arrow.apache.org/"
arch="all !s390x !riscv64" # missing glog-dev, thrift
license="Apache-2.0"
makedepends="
	apache-arrow-dev
	apache-arrow-static
	bzip2-dev
	cython
	gtest-dev
	python3-dev
	py3-setuptools
	py3-setuptools_scm
	py3-numpy-dev
	re2-dev
	snappy-dev
	"
checkdepends="
	py3-pytest
	py3-cffi
	py3-hypothesis
	py3-pandas
	py3-pytest-lazy-fixture
	tzdata
	"
subpackages="$pkgname-dev"
source="https://downloads.apache.org/arrow/arrow-$pkgver/apache-arrow-$pkgver.tar.gz"
builddir="$srcdir/apache-arrow-$pkgver"

build() {
	cd python

	case "$CARCH" in
		armhf|armv7) _SIMD="NONE" ;;
		*) _SIMD="DEFAULT" ;;
	esac
	export PYARROW_WITH_PARQUET=1
	python3 setup.py build_ext --inplace --extra-cmake-args="-DARROW_SIMD_LEVEL=$_SIMD -DPYARROW_BUILD_DATASET=ON"
}

check() {
	# test_memory.py test is jemalloc
	# other tests are various platforms
	cd python
	python3 setup.py install --root="test_install"
	export PYTHONPATH="$(echo $PWD/test_install/usr/lib/python3*/site-packages)"
	pytest pyarrow --deselect=pyarrow/tests/test_memory.py \
		--deselect=pyarrow/tests/test_csv.py \
		--deselect=pyarrow/tests/parquet/test_data_types.py \
		--deselect=pyarrow/tests/test_array.py::test_dictionary_to_numpy \
		--deselect=pyarrow/tests/test_io.py::test_python_file_large_seeks \
		--deselect=pyarrow/tests/test_io.py::test_foreign_buffer \
		--deselect=pyarrow/tests/test_io.py::test_memory_map_large_seeks \
		--deselect=pyarrow/tests/test_pandas.py::TestConvertStructTypes::test_from_numpy_nested \
		--deselect=pyarrow/tests/test_schema.py::test_schema_sizeof \
		--deselect=pyarrow/tests/test_serialization.py::test_primitive_serialization \
		--deselect=pyarrow/tests/test_serialization.py::test_integer_limits \
		--deselect=pyarrow/tests/parquet/test_dataset.py::test_partitioned_dataset
}

package() {
	cd python
	python3 setup.py install --prefix=/usr --root="$pkgdir"
}

sha512sums="
8280ce775c05296e33a292241c976caee2bddda7da396ef3c5da700347cb616a932475140139a5e96027781e71f66466e27fcf6423440bf720fbc83faabf0f3d  apache-arrow-8.0.0.tar.gz
"
